package com.zyx.order.server.controller;

import com.zyx.order.server.model.response.CommonResult;
import com.zyx.order.server.model.vo.OrderCreateVO;
import com.zyx.order.server.service.impl.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

@Slf4j
@RestController
@RequestMapping("/api/v1")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping("/orders")
    public CommonResult<Void> createOrder(@RequestBody OrderCreateVO orderCreateDTO) throws IOException, TimeoutException, InterruptedException {
        log.info("createOrder:orderCreateDTO:{}", orderCreateDTO);
        orderService.createOrder(orderCreateDTO);
        return CommonResult.success("成功创建订单");
    }

}
